package network.client;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

public class ChatWindow {
    public static void main(String[] args) {
        try(ServerSocket ss = new ServerSocket(Integer.parseInt(args[0]))) {
            while (true) {
                try (Socket s = ss.accept();
                     BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()))
                ) {
                    while (true) {
                        System.out.println(br.readLine());
                    }
                } catch (IOException e) {
                    System.err.println("Socket error: " + e.getMessage());
                }
            }
        } catch (IOException e) {
            System.err.println("Socket error: " + e.getMessage());
        }
    }
}
